package com.ssm.crud.controller;

import com.ssm.crud.entities.Department;
import com.ssm.crud.entities.Msg;
import com.ssm.crud.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/11/16 17:01
 */
@Controller
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @ResponseBody
    @RequestMapping("/depts")
    public Msg getAll() {
        List<Department> departments = departmentService.getDepts();
        Msg msg = Msg.success().add("deptments", departments);
        return msg;
    }

}
